using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Events;

public class MonoManager : Singleton<MonoManager>
{
    private MonoController monoController;

    public MonoManager()
    {
        GameObject obj = new GameObject("MonoController");
        monoController = obj.AddComponent<MonoController>();
    }

    public void AddUpdateEvent(UnityAction action)
    {
        monoController.AddUpdateEvent(action);
    }

    public void RemoveUpdateEvent(UnityAction action)
    {
        monoController.RemoveUpdateEvent(action);
    }

    public Coroutine StartCoroutine(IEnumerator routine)
    {
        return monoController.StartCoroutine(routine);
    }

    public Coroutine StartCoroutine(string methodName, object value = null)
    {
        return monoController.StartCoroutine(methodName, value);
    }

    /// <summary>
    /// 方法名只能是controller中的方法
    /// </summary>
    /// <param name="methodName"></param>
    /// <returns></returns>
    public Coroutine StartCoroutine(string methodName)
    {
        return monoController.StartCoroutine(methodName);
    }

    //停止协程
    public void StopCoroutine(Coroutine coroutine)
    {
        monoController.StopCoroutine(coroutine);
    }
    public void StopAllCoroutines()
    {
        monoController.StopAllCoroutines();
    }
}